import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import eventBus from '../tools/eventBus'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path:'/stopInfo',
    name:'stopInfo',
    component:()=>import('../components/stopInfo')
  },
  {
    path:'/airportInfo',
    name:'airportInfo',
    component:()=>import('../components/airportInfo')
  },
  {
    path:'/floorInfo',
    name:'floorInfo',
    component:()=>import('../components/floorInfo')
  },
  {
    path:'/stopStatus',
    name:'stopStatus',
    component:()=>import('../components/stopStatus')
  },
  {
    path:'/busdataArea',
    name:'busdataArea',
    component:()=>import('../components/busdataArea')
  },
  {
    path:'/vipdataArea',
    name:'vipdataArea',
    component:()=>import('../components/vipdataArea')
  },
  {
    path:'/safedataArea',
    name:'safedataArea',
    component:()=>import('../components/safedataArea')
  },
  {
    path:'/countryataArea',
    name:'countrydataArea',
    component:()=>import('../components/countrydataArea')
  },
  {
    path:'/dataArea',
    name:'dataArea',
    component:()=>import('../components/dataArea')
  },
  {
    path:'/passengerFlow',
    name:'passengerFlow',
    component:()=>import('../components/passengerFlow')
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({ 
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  if(to.path !=='/' || to.fullPath !=='/airportInfo'){
    eventBus.$emit('routetchange',from.fullPath)
    setTimeout(()=>{
      next()
    },800)
  }else{
    next()
  }
  
})
export default router
